package svc

import (
	"go-pod/api/internal/config"
	"go-pod/api/internal/middleware"
	"go-pod/pod-rpc/podclient"
	"go-pod/rpc/userclient"

	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config        config.Config
	Auth          rest.Middleware
	UserRpcClient userclient.User
	PodRpcClient  podclient.Pod
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:        c,
		Auth:          middleware.NewAuthMiddleware().Handle,
		UserRpcClient: userclient.NewUser(zrpc.MustNewClient(c.UserRpc)), // 创建 User 客户端
		PodRpcClient:  podclient.NewPod(zrpc.MustNewClient(c.PodRpc)),    // 创建 Pod 客户端
	}
}
